<div class="page-content">
    <div class="col-sm-6 pull-right">

        <button class="btn btn-sm btn-primary pull-right" onclick="javascript:window.location.href = '{:url("index")}'">
            返回列表
            <i class="icon-reply icon-only"></i>
        </button>
    </div>
    <div class="page-header">
        <h1>
            {:model('menu')->getParentNname()}
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                {:input('id')?'编辑':'新增'}
            </small>
        </h1>
    </div><!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <form class="form-horizontal" role="form" action="{:input('id')?url('edit'):url('add')}" method="post" name="myfrom" >
                {:input('id')?'<input type="hidden" value="'.$info['id'].'" name="id">':''}
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">测站编码</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.station_code|default=''}" name="station_code"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">断面类型</label>
                    <div class="col-sm-9" style="height: 32px;line-height: 36px">
                        <input type="radio"   name="type" value="1" {if condition="!isset($info['type']) || $info['type'] eq 1"}checked{/if}/> 常规采样&nbsp;&nbsp;
                        <input type="radio"   name="type" value="2" {if condition="isset($info['type']) && $info['type'] eq 2"}checked{/if}/> 临时采样
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">集团</label>
                    <div class="col-sm-9">
                        <select name="com_id" style="width: 300px">
                            <option value="0" />请选择集团</option>
                        {foreach name="company" item="v"}
                            <option value="{$v.id}" {if condition="$v.id eq $info.com_id"}selected{/if}>{$v.name}</option>
                        {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">测站名称</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.posname|default=''}" name="posname"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">样品类型</label>
                    <div class="col-sm-9">
                        <select name="tasktype_id" style="width: 300px">
                            <option value="0" />请选择样品类型</option>
                        {foreach name="taskType" item="v" key='k'}
                            <option value="{$k}" {if condition="$k eq $info.tasktype_id"}selected{/if}>{$v}</option>
                        {/foreach}
                        </select>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">经度</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.lng|default=''}" name="lng"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">维度</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.lat|default=''}" name="lat"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">地区</label>
                    <div class="col-sm-9">
                        <select name="province" onchange="getRegion(this,'city')">
                            <option value="" />请选择省份</option>
                            {foreach name="province" item="v"}
                            <option value="{$v.name}" data-id="{$v.id}" {if condition="$v.name eq $info['province']"}selected{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                        <select name="city" onchange="getRegion(this,'county')">
                            <option value="" />请选择市</option>
                            {foreach name="city" item="v"}
                            <option value="{$v.name}" data-id="{$v.id}" {if condition="$v.name eq $info['city']"}selected{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                        <select name="county">
                            <option value="" />请选择区县</option>
                            {foreach name="country" item="v"}
                            <option value="{$v.name}" data-id="{$v.id}" {if condition="$v.name eq $info['county']"}selected{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">测站地址</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.station_add|default=''}" name="station_add"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">流域</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.watershed|default=''}" name="watershed"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">水系</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.river_sys|default=''}" name="river_sys"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">河流</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.river_name|default=''}" name="river_name"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">管理单位</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.mus|default=''}" name="mus"/>
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">监测单位</label>
                    <div class="col-sm-9">
                        <input type="text" class="col-xs-10 col-sm-5" value="{$info.monus|default=''}" name="monus"/>
                    </div>
                </div>

                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right">状态</label>
                    <div class="col-sm-9" style="height: 32px;line-height: 36px">
                        <input type="radio"   name="status" value="1" {if condition="!isset($info['status']) || $info['status'] eq 1"}checked{/if}/> 启用&nbsp;&nbsp;
                        <input type="radio"   name="status" value="0" {if condition="isset($info['status']) && $info['status'] eq 0"}checked{/if}/> 禁用
                    </div>
                </div>
                <div class="space-4"></div>
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="button" onclick="myfrom.submit()">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            提交
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i>
                            重置
                        </button>
                    </div>
                </div>
            </form>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script>

    function getRegion(data,strName){

        var parent_id = $(data).find("option:selected").attr('data-id');

        var url = "{:url('getRegion')}";

        $.post(url,{parent_id:parent_id},function(res){
            var data = $.parseJSON(res)
            if(strName == 'city'){
                var html = '<option value="" >请选择市</option>';
            }else{
                var html = '<option value="" >请选择区县</option>';
            }


            for(let key  in data){

                 html+="<option value='"+data[key].name+"'  data-id='"+data[key].id+"'>"+data[key].name+"</option>"
            }

            $("select[name='"+strName+"']").html(html);
        }, 'json')
    }


</script>